package util;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.example.University;

import java.util.List;

public class UniversityControllerHelper {
    //增加
    public static University getAdd(JSONObject req_jsonObj){
        JSONObject university_jsonArray = req_jsonObj.getJSONObject("add");
        University university = null;
        if (university_jsonArray != null){
            university = university_jsonArray.toJavaObject(University.class);
        }
        return university;
    }
    public static List<Condition> getCondition(JSONObject req_jsonObj){
        JSONArray conditionList_jsonArray = req_jsonObj.getJSONArray("conditionList");
        List<Condition> conditionList = null;
        if (conditionList_jsonArray != null){
            conditionList = conditionList_jsonArray.toJavaList(Condition.class);
        }
        return conditionList;
    }
    //查
    public static Pagination getPagination(JSONObject req_jsonObj){
        JSONObject pagination_jsonObj = req_jsonObj.getJSONObject("pagination");
        Pagination pagination = null;
        if (pagination_jsonObj !=null){
            pagination = pagination_jsonObj.toJavaObject(Pagination.class);
        }
        return pagination;
    }
    //删除
    public static University getUpdate(JSONObject req_jsonObj){
        JSONObject university_jsonArray = req_jsonObj.getJSONObject("Update");
        University univeristy = null;
        if (university_jsonArray != null){
            univeristy = university_jsonArray.toJavaObject(University.class);
        }
        return univeristy;
    }
}
